<template>
    <div class="FinanceTable">
        <Breadcrumb :Breadcrumb="Breadcrumb" :hasBack = "false"></Breadcrumb>
        <div class="content">
            <tableComponent :tableData = "tableData" :tableLabel = "tableLabel" :tableOption = "tableOption" />
        </div>
    </div>
</template>
<script>
export default {
    components:{
        Breadcrumb : () => import('@/components/IncorruptibleArchives/Breadcrumb.vue'),
        tableComponent : () => import('../../comonComponent/table')
    },
    data() {
        return{
            Breadcrumb:[
                { name: "监督举报", link: "Expenditure" },
                { name: "动态监督", link: "" },
                { name: "财务监督", link: "Finance" },
                { name: "现金流量数据表", link: "" }
            ],
            tableData: [],
            tableLabel: [
                { prop : 'mon', label : '月度', minWidth: '100', fixed : false, render : false, align : 'center'},
                { prop : 'orgName', label : '单位名称', minWidth: '160', fixed : false, render : false, align : 'center'}
            ],
            tableOption : {
                loading: false,
                stripe: false,
                highlightCurrentRow : false,
                border : true,
                height : 610,
                maxHeight : '',
                resizable: false,
                headerCellStyle: {lineHeight: '46px', background: '#FAFAFA', padding: 0 },
                cellStyle: {height: '50px', padding: 0 }
            }
        }
    },
    created(){
        if (this.$route.query.comeFrom === 'assetsChange') {
            this.Breadcrumb[this.Breadcrumb.length-1].name = '资产变动情况数据表'
            let labelOPtion = [
                { prop : 'fixAssets', label : '固定资产', minWidth: '160', fixed : false, render : false, align : 'center'},
                { prop : 'intangibleAssets', label : '无形资产', minWidth: '160', fixed : false, render : false, align : 'center'},
                { prop : 'currentAssets', label : '流动资产', minWidth: '160', fixed : false, render : false, align : 'center'},
                { prop : 'totalAssets', label : '总资产', minWidth: '160', fixed : false, render : false, align : 'center'},
            ]
            this.tableLabel = [...this.tableLabel, ...labelOPtion]
        } else  if (this.$route.query.comeFrom === 'cashFlow') {
            this.Breadcrumb[this.Breadcrumb.length-1].name = '现金流量数据表'
            let labelOPtion = [
                { prop : 'management', label : '经营活动产生的现金流量', minWidth: '160', fixed : false, render : false, align : 'center'},
                { prop : 'investment', label : '投资活动产生的现金流量', minWidth: '160', fixed : false, render : false, align : 'center'},
                { prop : 'financing', label : '筹资活动产生的现金流量', minWidth: '160', fixed : false, render : false, align : 'center'},
                { prop : 'increase', label : '现金净增加额', minWidth: '160', fixed : false, render : false, align : 'center'},
                { prop : 'balance', label : '现金余额', minWidth: '160', fixed : false, render : false, align : 'center'},
            ]
            this.tableLabel = [...this.tableLabel, ...labelOPtion]
        } else  if (this.$route.query.comeFrom === 'profit') {
            this.Breadcrumb[this.Breadcrumb.length-1].name = '利润数据表'
            let labelOPtion = [
                { prop : 'income', label : '主营业务收入', minWidth: '160', fixed : false, render : false, align : 'center'},
                { prop : 'cost', label : '主营业务成本', minWidth: '160', fixed : false, render : false, align : 'center'},
                { prop : 'taxes', label : '主营业务税金及附加', minWidth: '160', fixed : false, render : false, align : 'center'},
                { prop : 'profit', label : '主营业务利润', minWidth: '160', fixed : false, render : false, align : 'center'},
            ]
            this.tableLabel = [...this.tableLabel, ...labelOPtion]
        } else {
            this.$router.go(-1)
        }
    },
    mounted() {
        this.queryData()
    },
    methods:{
        queryData() {
            let data = JSON.parse(this.$route.query.queryData)
            let Request = this.$route.query.comeFrom === 'assetsChange' ? this.Api.getAssetsChangeQuery(data) : 
                this.$route.query.comeFrom === 'cashFlow' ? this.Api.getCashFlowQuery(data) :
                this.$route.query.comeFrom === 'profit' ? this.Api.getProfitQuery(data) : ''
            Request.then(res => {
                if (res && res.code === '0') {
                    this.tableData = res.data
                } else {
                    this.tableData = []
                }
            })
        }
    }
}
</script>
<style lang="less" scoped>
    .FinanceTable{
         .content{
             width: 100%;
             height: 100%;
         }
    }
</style>